
package org.apache.solr.highlight;

import org.apache.lucene.search.vectorhighlight.BoundaryScanner;
import org.apache.solr.common.params.HighlightParams;
import org.apache.solr.common.params.SolrParams;

public class SimpleBoundaryScanner extends SolrBoundaryScanner {

    @Override
    protected BoundaryScanner get(String fieldName, SolrParams params) {

        int maxScan = params.getFieldInt(fieldName, HighlightParams.BS_MAX_SCAN, 10);
        String str = params.getFieldParam(fieldName, HighlightParams.BS_CHARS, ".,!? \t\n");
        Character[] chars = new Character[str.length()];
        for(int i = 0; i < str.length(); i++) {
            chars[i] = str.charAt(i);
        }
        return new org.apache.lucene.search.vectorhighlight.SimpleBoundaryScanner(maxScan, chars);
    }

    // SolrInfoMBeans methods
    @Override
    public String getDescription() {
        return "SimpleBoundaryScanner";
    }

    @Override
    public String getSource() {
        return "$URL: https://svn.apache.org/repos/asf/lucene/dev/branches/lucene_solr_4_0/solr/core/src/java/org/apache/solr/highlight/SimpleBoundaryScanner.java $";
    }
}
